package com.s64.service;

import com.s64.dao.SysUserDao;
import com.s64.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService implements IUserService {
    @Autowired
    private SysUserDao sysUserDao;

    public Page<SysUser> getAll(PageRequest pageRequest) {
        return sysUserDao.findAll(pageRequest);
    }

    @Override
    public SysUser add(SysUser user) {
        return sysUserDao.save(user);
    }

    @Override
    public int del(Integer id) {
        sysUserDao.deleteById(id);
        return 1;
    }

    @Override
    public SysUser update(SysUser user) {
        return sysUserDao.save(user);
    }

    @Override
    public SysUser get(Integer id) {
        return sysUserDao.findById(id).get();
    }
}
